const express = require('express');
const auth = require('../../middleware/auth');

const router = express.Router();

// 获取安全告警
router.get('/alerts', auth, async (req, res) => {
  try {
    const alerts = [
      {
        id: '1',
        type: 'intrusion',
        level: 'high',
        message: '检测到异常入侵',
        location: 'A区入口',
        timestamp: new Date().toISOString()
      },
      {
        id: '2',
        type: 'fire',
        level: 'medium',
        message: '烟雾报警器触发',
        location: '办公楼2层',
        timestamp: new Date(Date.now() - 1800000).toISOString()
      }
    ];

    res.json(alerts);
  } catch (error) {
    console.error('Get security alerts error:', error);
    res.status(500).json({ error: '获取安全告警失败' });
  }
});

module.exports = router;
